class Solution
{
public:
    int minDeletion(vector<int> &nums)
    {
        vector<int> beautifulNums;
        for (int num : nums)
        {
            if (beautifulNums.size() & 1)
            {
                if (num == beautifulNums.back())
                {
                    continue;
                }
                else
                {
                    beautifulNums.push_back(num);
                }
            }
            else
            {
                beautifulNums.push_back(num);
            }
        }
        if (beautifulNums.size() & 1)
        {
            beautifulNums.pop_back();
        }
        return nums.size() - beautifulNums.size();
    }
};